import { createRouter, createWebHistory } from 'vue-router'

import type { App } from 'vue'
import type { RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    component: () => import('@/views/home/index.vue')
  },
  {
    path: '/tool/pinia',
    component: () => import('@/views/tool/pinia.vue')
  },
  {
    path: '/tool/scss',
    component: () => import('@/views/tool/scss.vue')
  },
  {
    path: '/tool/svg',
    component: () => import('@/views/tool/svg.vue')
  },
  {
    path: '/tool/rem',
    component: () => import('@/views/tool/rem.vue')
  },
  {
    path: '/tool/imageCompression',
    component: () => import('@/views/tool/imageCompression.vue')
  }
]

const router = createRouter({
  routes,
  history: createWebHistory()
})

// eslint-disable-next-line import/prefer-default-export
const useRouter = (app: App) => {
  app.use(router)
}
export default useRouter
